//
//  KKEmoticonButton.swift
//  EmotionKeyBoard
//
//  Created by King.Kong. on 16/6/1.
//  Copyright © 2016年 King.Kong. All rights reserved.
//

import UIKit

class KKEmoticonButton: UIButton {

    var emoticon: KKEmoticon? {
        didSet {
            if let imagePath = emoticon?.imagePath {
                setImage(UIImage(named: imagePath), forState: .Normal)
                setTitle(nil, forState: .Normal)
            } else {
                if let title = emoticon?.emoji {
                    setTitle(title, forState: .Normal)
                    setImage(nil, forState: .Normal)
                }
            }
           
            //给删除按钮设置图片
            if emoticon!.isDelete {
                setImage(UIImage(named: "compose_emotion_delete"), forState: .Normal)
            }
            
            if emoticon!.isEmpty {
                setTitle(nil, forState: .Normal)
                setImage(nil, forState: .Normal)
            }

        }
        
        
    }

}
